package com.ruoyi.train.service.impl;

import java.util.List;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.train.domain.Vo.StudentInformationVo;
import com.ruoyi.train.mapper.StudentInformationMapper;
import com.ruoyi.train.mapper.TrainPlanMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.train.mapper.StudentProcessRecordMapper;
import com.ruoyi.train.domain.StudentProcessRecord;
import com.ruoyi.train.service.IStudentProcessRecordService;

/**
 * 学员三项岗位进程记录Service业务层处理
 * 
 * @author wusihao
 * @date 2023-03-22
 */
@Service
public class StudentProcessRecordServiceImpl extends ServiceImpl<StudentProcessRecordMapper, StudentProcessRecord> implements IStudentProcessRecordService
{
    @Autowired
    private StudentProcessRecordMapper studentProcessRecordMapper;

    @Autowired
    private StudentInformationMapper studentInformationMapper;

    @Autowired
    private TrainPlanMapper trainPlanMapper;

    /**
     * 查询学员三项岗位进程记录
     * 
     * @param id 学员三项岗位进程记录主键
     * @return 学员三项岗位进程记录
     */
    @Override
    public StudentProcessRecord selectStudentProcessRecordById(Long id)
    {
        return studentProcessRecordMapper.selectStudentProcessRecordById(id);
    }

    /**
     * 查询学员三项岗位进程记录列表
     * 
     * @param studentProcessRecord 学员三项岗位进程记录
     * @return 学员三项岗位进程记录
     */
    @Override
    public List<StudentProcessRecord> selectStudentProcessRecordList(StudentProcessRecord studentProcessRecord)
    {
        return studentProcessRecordMapper.selectStudentProcessRecordList(studentProcessRecord);
    }

    /**
     * 新增学员三项岗位进程记录
     * 
     * @param studentProcessRecord 学员三项岗位进程记录
     * @return 结果
     */
    @Override
    public int insertStudentProcessRecord(StudentProcessRecord studentProcessRecord)
    {
        return studentProcessRecordMapper.insertStudentProcessRecord(studentProcessRecord);
    }

    /**
     * 修改学员三项岗位进程记录
     * 
     * @param studentProcessRecord 学员三项岗位进程记录
     * @return 结果
     */
    @Override
    public int updateStudentProcessRecord(StudentProcessRecord studentProcessRecord)
    {
        return studentProcessRecordMapper.updateStudentProcessRecord(studentProcessRecord);
    }

    /**
     * 批量删除学员三项岗位进程记录
     * 
     * @param ids 需要删除的学员三项岗位进程记录主键
     * @return 结果
     */
    @Override
    public int deleteStudentProcessRecordByIds(Long[] ids)
    {
        return studentProcessRecordMapper.deleteStudentProcessRecordByIds(ids);
    }

    /**
     * 删除学员三项岗位进程记录信息
     * 
     * @param id 学员三项岗位进程记录主键
     * @return 结果
     */
    @Override
    public int deleteStudentProcessRecordById(Long id)
    {
        return studentProcessRecordMapper.deleteStudentProcessRecordById(id);
    }

    // 提交考试结论到学生记录
    @Override
    public int submitExamConclusion(StudentInformationVo studentInformationVo) {
        String serialNumber = studentInformationVo.getSerialNumber();
        QueryWrapper<StudentProcessRecord> studentProcessRecordQueryWrapper = new QueryWrapper<>();
        studentProcessRecordQueryWrapper.eq("serial_number", serialNumber);
        StudentProcessRecord studentProcessRecord = studentProcessRecordMapper.selectOne(studentProcessRecordQueryWrapper);
        studentProcessRecord.setTrainConclusion(studentInformationVo.getTrainConclusion());
        return studentProcessRecordMapper.updateById(studentProcessRecord);
    }
}
